package com.lmc.form.controller;

import com.free.bsf.core.base.BsfException;
import com.free.bsf.core.util.ContextUtils;
import com.free.bsf.core.util.PropertyUtils;
import com.free.bsf.file.FileProvider;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import lombok.var;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

@Slf4j
@Controller
@RequestMapping("/")
public class HomeController extends SpringMvcController {
	
    @RequestMapping("/index/")
    public String index()
    {
        return "/home/index";
    }

    @RequestMapping("/")
    public ModelAndView demo()
    {
        return pageVisit((m) -> {
             m.setViewName("/home/demo");
        });
    }
    @RequestMapping("/flex/")
    public ModelAndView flex()
    {
        return pageVisit((m) -> {
            m.setViewName("/home/flex");
        });
    }
    @RequestMapping("/formold")
    public ModelAndView formold()
    {
        return pageVisit((m) -> {
            m.setViewName("/home/formold");
        });
    }
    @RequestMapping("/flexformold")
    public ModelAndView flexformold()
    {
        return pageVisit((m) -> {
            m.setViewName("/home/flexformold");
        });
    }
    @RequestMapping("/sort/")
    public ModelAndView sort()
    {
        return pageVisit((m) -> {
            m.setViewName("/home/sort");
        });
    }
//    /**
//     * 登录页面
//     * */
//    @RequestMapping(value="/login",method=RequestMethod.GET)
//    public String login_page()
//    {
//        return "/home/index";
//    }
//    /**
//     * 登录
//     * */
//    @RequestMapping(value="/login.do",method=RequestMethod.POST)
//    public String login(String username,String password)
//    {
//        if(PropertyUtils.getPropertyCache("flow.userno","").equals(username)&&
//                PropertyUtils.getPropertyCache("flow.password","").equals(password))
//        {//登录成功
//            val user = DbHelper.noTransactionGet((c)->{
//                return new t_user_dal().getByNo(c,PropertyUtils.getPropertyCache("flow.userno",""));
//            });
//            if(user!=null) {
//                User u = new User(user.name, user.no, user.email, user.mobile,password);
//                User.setCurrent(u);
//                //return "redirect:user/flow/lunched_list";
//                return "redirect:/manager/flow/index";
//            }
//        }
//        //log.info("登录信息："+JSON.toJSONString(reponse));
//        return "/home/index";
//    }
//
//    @RequestMapping(value="/logout",method=RequestMethod.GET)
//    public String logout()
//    {
//        User.setCurrent(null);
//        return "/home/index";
//    }
//    @RequestMapping(value="/upload")
//    public ModelAndView upload(MultipartFile system_file){
//        html.s2("checkuser",false);
//        return jsonVisit((m)->{
//            try {
//                FileProvider fileProvider = ContextUtils.getBean(FileProvider.class, false);
//                var url = fileProvider.upload(system_file.getInputStream(), system_file.getOriginalFilename());
//                return url+"?filename="+system_file.getOriginalFilename();
//            }catch (Exception e){
//                throw new BsfException(e);
//            }
//        });
//    }
}
